package com.bmp.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.bmp.dao.ProStatusDao;
import com.bmp.model.ProStatus;
import com.bmp.model.User;
import com.bmp.util.HibernateUtil;

@Component("proStatusDao")
public class ProStatusDaoImpl implements ProStatusDao {

	private HibernateTemplate hibernateTemplate;

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	/* (non-Javadoc)
	 * @see com.bmp.dao.ProStatusDao#getProStatusById(int)
	 */
	public ProStatus getProStatusById(int id) {
		return (ProStatus) this.hibernateTemplate.get(ProStatus.class, id);
	}

	/* (non-Javadoc)
	 * @see com.bmp.dao.ProStatusDao#getAllProStatus()
	 */
	public List<ProStatus> getAllProStatus() {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.getCurrentSession();
		session.beginTransaction();
		String sql = "from ProStatus p";
		List<ProStatus> proStatus  = session.createQuery(sql).list();
		//List<User> users = hibernateTemplate.find("from User u");	
		return proStatus;
	}
	
	

}
